import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import App from './App.vue'
import router from './router'
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap-icons/font/bootstrap-icons.css'

// 导入样式
import './styles/theme.css'
import './styles/chat.css'
import './styles/voiceInput.css'
import './styles/voicePlayer.css'
import './styles/voiceHighlighter.css'
import './styles/avatarPlayer.css'
import './styles/fileUpload.css'

// 导入 Prism.js
import Prism from 'prismjs'
import 'prismjs/themes/prism.css'

// 动态导入语言组件
const loadPrismComponents = async () => {
  try {
    // 先加载核心组件
    await import('prismjs/components/prism-core')
    await import('prismjs/components/prism-markup')
    
    // 再加载语言组件
    await import('prismjs/components/prism-java')
    await import('prismjs/components/prism-python')
    await import('prismjs/components/prism-javascript')
    await import('prismjs/components/prism-bash')
    await import('prismjs/components/prism-sql')
  } catch (error) {
    console.error('加载 Prism 组件失败:', error)
  }
}

// 加载 Prism 组件
loadPrismComponents()

const app = createApp(App)

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(createPinia())
app.use(router)
app.use(ElementPlus)

app.mount('#app')
